home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / devel / tcl / tclx7_31.z / tclx7_31 / tcldev / tclX7.3a-p1 / tests / clock.test < prev    next >
Encoding:
Text File  |  1994-01-23  |  3.5 KB  |  112 lines

  1. #
  2. # clock.test
  3. #
  4. # Tests for the getclock, fmtclock and convertclock commands.
  5. #---------------------------------------------------------------------------
  6. # Copyright 1992-1993 Karl Lehenbauer and Mark Diekhans.
  7. #
  8. # Permission to use, copy, modify, and distribute this software and its
  9. # documentation for any purpose and without fee is hereby granted, provided
  10. # that the above copyright notice appear in all copies.  Karl Lehenbauer and
  11. # Mark Diekhans make no representations about the suitability of this
  12. # software for any purpose.  It is provided "as is" without express or
  13. # implied warranty.
  14. #------------------------------------------------------------------------------
  15. # $Id: clock.test,v 3.1 1994/01/11 04:35:36 markd Exp $
  16. #------------------------------------------------------------------------------
  17. #
  18.  
  19. if {[info procs test] != "test"} then {source testlib.tcl}
  20.  
  21. # Try getclock, hard to test the result, make sure its a number
  22.  
  23. Test clock-1.1 {getclock tests} {
  24.     expr [getclock]+1
  25.     concat {}
  26. } 0 {}
  27.  
  28. Test clock-1.2 {getclock tests} {
  29.     getclock 1990
  30. } 1 {wrong # args: getclock}
  31.  
  32. # Test fmtclock
  33.  
  34. Test clock-2.1 {fmtclock tests} {
  35.     set clockval 657687766
  36.     fmtclock $clockval {%a %b %d %I:%M:%S %p %Y} GMT
  37. } 0 {Sun Nov 04 03:02:46 AM 1990}
  38.  
  39. Test clock-2.2 {fmtclock tests} {
  40.     fmtclock
  41. } 1 {wrong # args: fmtclock clockval ?format? ?GMT|{}?}
  42.  
  43. # Test convertclock
  44.  
  45. Test clock-3.1 {convertclock tests} {
  46.     convertclock
  47. } 1 {wrong # args: convertclock dateString ?GMT|{}? ?baseclock?}
  48.  
  49. Test clock-3.2 {convertclock tests} {
  50.     fmtclock [convertclock "14 Feb 92" GMT] {%m/%d/%y %I:%M:%S %p} GMT
  51. } 0 {02/14/92 12:00:00 AM}
  52.  
  53. Test clock-3.3 {convertclock tests} {
  54.     fmtclock [convertclock "Feb 14, 1992 12:20 PM" GMT] {%m/%d/%y %I:%M:%S %p} GMT
  55. } 0 {02/14/92 12:20:00 PM}
  56.  
  57. Test clock-3.5 {convertclock tests} {
  58.     fmtclock [convertclock "Feb 14, 1992 12:20 PM" {GMT} 319363200] {%m/%d/%y %I:%M:%S %p} GMT
  59. } 0 {02/14/92 12:20:00 PM}
  60.  
  61. Test clock-3.6 {convertclock tests} {
  62.     set clock [convertclock "Oct 23,1992 15:00"]
  63.     fmtclock $clock {%b %d,%Y %H:%M}
  64. } 0 {Oct 23,1992 15:00}
  65.  
  66. Test clock-3.7 {convertclock tests} {
  67.     set clock [convertclock "Oct 23,1992 15:00 GMT"]
  68.     fmtclock $clock {%b %d,%Y %H:%M GMT} GMT
  69. } 0 {Oct 23,1992 15:00 GMT}
  70.  
  71.  
  72. Test clock-3.8 {convertclock tests} {
  73.     set clock [convertclock "Oct 23,1992 15:00" GMT]
  74.     fmtclock $clock {%b %d,%Y %H:%M GMT} GMT
  75. } 0 {Oct 23,1992 15:00 GMT}
  76.  
  77.  
  78. # Test if local timezone works when not explicitly specified.
  79.  
  80. Test clock-3.9 {convertclock tests} {
  81.     # WARNING: This test might fail if your symbolic timezone name conflicts
  82.     # with names use in other parts of the world.  Known failures:
  83.     #
  84.     #    EST for Australian Eastern Summer Time.
  85.     #    EST for Australian Eastern Standard Time.
  86.     #
  87.     # Don't worry about these failures.
  88.  
  89.     set clock [getclock]
  90.     set ourzone [fmtclock $clock %Z]
  91.     set intime [fmtclock $clock {%a %h %d %T %Y}]
  92.  
  93.     set cnv1 [convertclock $intime]
  94.     set cnv2 [convertclock "$intime $ourzone"]
  95.     expr {$cnv1 == $cnv2}
  96. } 0 1
  97.  
  98. set fmt {%m/%d/%y %I:%M:%S %p}
  99. foreach hour {01 02 03 04 05 06 07 08 09 10 11 12} {
  100.    foreach min {00 01 59} {
  101.        foreach med {AM PM} {
  102.            Test clock-4.0 {convertclock tests} {
  103.                 fmtclock [convertclock "1/1/72 $hour:$min:00 $med"] $fmt
  104.            } 0 "01/01/72 $hour:$min:00 $med"
  105.  
  106.            Test clock-4.1 {convertclock tests} {
  107.                 fmtclock [convertclock "1/1/72 $hour:$min:00 $med" GMT] $fmt GMT
  108.            } 0 "01/01/72 $hour:$min:00 $med"
  109.        }
  110.    }
  111. }
  112.